<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="/CourseDesign4/manage/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="/CourseDesign4/manage/css/main.css"/>
</head>
<body>
	<!-- 菜单 -->
	<%@ include file="admin_menu.jsp" %>
	
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="admin_index.jsp">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">用户管理</span></div>
        </div>
        <div class="search-wrap">
            <div class="search-content">
                <form action="/CourseDesign4/manage/admin_douserquery" method="get">
                    <table class="search-tab">
                        <tr>
                            <!-- <th width="120">选择分类:</th>
                            <td>
                                <select name="search-sort" id="">
                                    <option value="">全部</option>
                                    <option value="19">精品界面</option><option value="20">推荐界面</option>
                                </select>
                            </td> -->
                            <th width="70">关键字:</th>
                            <td><input class="common-text" placeholder="关键字" name="keywords" value="${param.keywords}" id="" type="text"></td>
                            <td><input class="btn btn-primary btn2" name="sub" value="查询" type="submit"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="result-wrap">
            <form action="/CourseDesign4/manage/admin_douserdel" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <a href="admin_useradd.jsp"><i class="icon-font"></i>新增用户</a>
                        <a id="batchDel" href="javascript:delmore('确定删除这些用户吗?','myform')"><i class="icon-font"></i>批量删除</a>
                        <!-- <a id="updateOrd" href="javascript:void(0)"><i class="icon-font"></i>更新排序</a> -->
                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th class="tc" width="5%"><input class="allChoose" onclick="selectAll(this)" name="" type="checkbox"></th>
                            <th>ID</th>
                            <th>姓名</th>
                            <th>性别</th>
                            <th>Email</th>
                            <th>手机</th>
                            <th>地址</th>
                            <th>操作</th>
                        </tr>
                        
                        <!-- 使用JSTL遍历输出用户信息 -->
                        <c:forEach items="${userlist}" var="u">
	                        <tr>
	                            <td class="tc"><input name="id[]" value="${u.id}" type="checkbox"></td>
	                            <td>${u.id}</td>
	                            <td>${u.username}</td> 
	                            <td>${u.sex=='T'?'男':'女'}</td>
	                            <td>${u.email}</td>
	                            <td>${u.phone}</td>
	                            <td>${u.address}</td>
	                            <td>
	                                <a class="link-update" href="/CourseDesign4/manage/admin_userupdate?id=${u.id}&cpage=${cpage}">修改</a>
	                                <c:if test="${u.status==1}">
	                                	<a class="link-del" href="javascript:delUser('你确定删除用户[${u.username}]吗?','/CourseDesign4/manage/admin_douserdel?id=${u.id}&cp=${cpage}')">删除</a>
	                                </c:if> 	
	                            </td>
	                        </tr>
                        </c:forEach>
                        
                        <script>
                        	// 删除判断函数
                        	function delUser(mess, url)
                        	{
                        		var flag = confirm(mess);
                        		if(flag) location.href = url;
                        	}
                        	
                        	// 全选
                        	function selectAll(tem)
                        	{
                        		var alls = document.getElementsByName("id[]");
                        		for(var i=0 ; i<alls.length ; i+=1)
                        		{
                        			alls[i].checked = tem.checked;
                        		}
                        	}
                        	
                        	// 批量删除
                        	function delmore(msg, id)
                        	{
                        		var flag = confirm(msg);
                        		if(flag)
                        		{
                        			var form = document.getElementById(id);
                        			form.submit();
                        		}
                        	}
                        </script>
                        
                    </table>
                    <div class="list-page">
                    	共 ${total} 条记录 当前 ${cpage}/${pagesum} 页
                    	<a href="/CourseDesign4/manage/admin_douserquery?cp=1${searchParams}">首页</a>
                    	<a href="/CourseDesign4/manage/admin_douserquery?cp=${cpage-1 < 1 ? 1 : (cpage-1)}${searchParams}">上一页</a>
                    	<a href="/CourseDesign4/manage/admin_douserquery?cp=${cpage+1 > pagesum ? pagesum : (cpage+1)}${searchParams}">下一页</a>
                    	<a href="/CourseDesign4/manage/admin_douserquery?cp=${pagesum}${searchParams}">尾页</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!--/main-->
</div>
</body>
</html>